package com.zhanghe.security.authenticationtoken;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class GithubAuthenticationToken extends AbstractAuthenticationToken {

    public String code;

    public String principal;

    public GithubAuthenticationToken( String code) {
        super(null);
        this.code = code;
    }

    public GithubAuthenticationToken(Collection<? extends GrantedAuthority> authorities, String code, String principal) {
        super(authorities);
        this.code = code;
        this.principal = principal;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setPrincipal(String principal) {
        this.principal = principal;
    }

    /**
     * 用户凭证
     * @return
     */
    @Override
    public Object getCredentials() {
        return null;
    }

    /**
     * 用户标识
     * @return
     */
    @Override
    public Object getPrincipal() {
        return principal;
    }
}
